package com.wang.springbootinit.controller;

import com.wang.springbootinit.common.BaseResponse;
import com.wang.springbootinit.common.ResultUtils;
import com.wang.springbootinit.model.entity.Exemption;
import com.wang.springbootinit.model.vo.ExemptionVO;
import com.wang.springbootinit.service.ExemptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 免测试申请控制器
 * 处理与免测申请相关的所有HTTP请求
 *
 * @author wang
 */
@RestController
@RequestMapping("/student/exemption")
public class ExemptionController {
    @Autowired
    private ExemptionService exemptionService;

    @PostMapping("/submit")
    public BaseResponse<Boolean> submitExemption(@RequestBody Exemption exemption,HttpServletRequest request) {
        return ResultUtils.success(exemptionService.submitExemption(exemption,request));
    }

    @GetMapping("/getByStudentId")
    public BaseResponse<List<Exemption>> getMyExemptions(@RequestParam Long studentId) {
        return ResultUtils.success(exemptionService.getMyExemptions(studentId));
    }

    @GetMapping("/getCurrentList")
    public BaseResponse<List<ExemptionVO>> getCurrentList(HttpServletRequest request){
        return ResultUtils.success(exemptionService.getCurrentList(request));
    }

    @GetMapping("/get/{id}")
    public BaseResponse<Exemption> getExemptionById(@PathVariable("id") Long exemptionId) {
        return ResultUtils.success(exemptionService.getExemptionById(exemptionId));
    }
} 